//
//  TTTabViewController.m
//  TrainTrack
//
//  Created by Jonathan Bunde-Pedersen on 04/10/08.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import "TTTabViewController.h"
#import "TTFavoriteStationsViewController.h"
#import "TTNearbyStationsViewController.h"

@implementation TTTabViewController

@synthesize allStationsController, favStationsController, nearbyStationsController;

// Override initWithNibName:bundle: to load the view using a nib file then perform additional customization that is not appropriate for viewDidLoad.
/*- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        
	    self.view.frame = [[UIScreen mainScreen] applicationFrame];
	    
	    self.allStationsController = [[TTStationsViewController alloc] initWithNibName:nil bundle:nil];
	    
	    self.viewControllers = [NSArray arrayWithObjects:self.allStationsController,nil];
	    self.selectedViewController = self.allStationsController;
	    
    }
    return self;
}*/

- (id) init {
	self = [super init];
	
	self.view.frame = [[UIScreen mainScreen] applicationFrame];
	
	TTStationsViewController *allStations = [[TTStationsViewController alloc] initWithNibName:nil bundle:nil];
	allStations.title = @"Alle Stationer";
	
	TTStationsViewController *favStations = [[TTFavoriteStationsViewController alloc] initWithNibName:nil bundle:nil];
	favStations.title = @"Favoritter";

	TTStationsViewController *nearbyStations = [[TTNearbyStationsViewController alloc] initWithNibName:nil bundle:nil];
	nearbyStations.title = @"Stationer i Området";

	self.allStationsController = [[UINavigationController alloc] initWithRootViewController:allStations];
	self.allStationsController.navigationBar.barStyle = UIBarStyleBlackOpaque;
	self.favStationsController = [[UINavigationController alloc] initWithRootViewController:favStations];
	self.favStationsController.navigationBar.barStyle = UIBarStyleBlackOpaque;
	self.nearbyStationsController = [[UINavigationController alloc] initWithRootViewController:nearbyStations];
	self.nearbyStationsController.navigationBar.barStyle = UIBarStyleBlackOpaque;
	
	
	allStations.navigationController = self.allStationsController;
	favStations.navigationController = self.favStationsController;
	nearbyStations.navigationController = self.nearbyStationsController;
	
	self.favStationsController.title = NSLocalizedString(@"Favoritter", @"FavStations");
	self.favStationsController.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemFavorites tag:0];
	
	self.allStationsController.title = NSLocalizedString(@"Alle Stationer", @"AllStations");
	self.allStationsController.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Alle Stationer" image:[UIImage imageNamed:@"ikon_tog.png"] tag:1];
	
	self.nearbyStationsController.title = NSLocalizedString(@"Stationer i Området", @"NearbyStations");
	self.nearbyStationsController.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Stationer i Området" image:[UIImage imageNamed:@"ikon_nearby.png"] tag:2];
	
	self.viewControllers = [NSArray arrayWithObjects:self.favStationsController,self.nearbyStationsController,self.allStationsController,nil];
	self.selectedViewController = self.favStationsController;
	return self;
}

/*
// Implement loadView to create a view hierarchy programmatically.
- (void)loadView {
}
*/

/*
// Implement viewDidLoad to do additional setup after loading the view.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
	return (interfaceOrientation == UIInterfaceOrientationPortrait);
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
    // Release anything that's not essential, such as cached data
}


- (void)dealloc {
    [super dealloc];
}


@end
